using System;
using FreeDraw;
using UnityEngine;
using UnityEngine.UI;

public class BrushSizeController : MonoBehaviour
{
	[SerializeField]
	private Image m_FillBar;

	private const int c_MinSize = 5;

	private const int c_MaxSize = 25;

	public static event Action<float> OnValueChangedEvent;

	private void Awake()
	{
		ColorButton.OnColorButtonClicked += OnColorButtonClicked;
	}

	private void OnDestroy()
	{
		ColorButton.OnColorButtonClicked -= OnColorButtonClicked;
	}

	private void OnColorButtonClicked(Color _Color)
	{
		m_FillBar.color = _Color;
	}

	public void OnValueChanged(float _Value)
	{
		Drawable.Pen_Width = Mathf.FloorToInt(Mathf.Lerp(5f, 25f, _Value));
		BrushSizeController.OnValueChangedEvent?.Invoke(_Value);
	}
}
